﻿<UserControl x:Name="userControl"
             x:Class="Rio.Framework.Pages.UserControls.Thumbnail"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:local="clr-namespace:Rio.Framework.Pages.UserControls"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="400">

    <UserControl.Resources>
        <local:NumberPagesToVisibilityConverter x:Key="NumberPagesToVisibilityConverter" />
        <local:WorkflowStateToIconConverter x:Key="WorkflowStateToIconConverter" />
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="VisualStateGroup">

                <VisualState x:Name="CopiedOrPastedState">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                       Storyboard.TargetName="rectangle">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <VisualState x:Name="FulltextState">
                    <Storyboard>
                        <ColorAnimation Duration="0"
                                        To="#FFE90000"
                                        Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)"
                                        Storyboard.TargetName="border"
                                        d:IsOptimized="True" />
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderThickness)"
                                                       Storyboard.TargetName="border">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Thickness>2</Thickness>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.CornerRadius)"
                                                       Storyboard.TargetName="border">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <CornerRadius>1</CornerRadius>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                       Storyboard.TargetName="rectangle">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <VisualState x:Name="DefaultState">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                                       Storyboard.TargetName="rectangle">
                            <DiscreteObjectKeyFrame KeyTime="0">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>

        <Image Source="/Rio.Framework.Pages;component/Assets/Images/GlassBackground.png"
               Opacity="0.8"
               Stretch="Fill" />

        <Rectangle x:Name="rectangle"
                   Visibility="Collapsed"
                   Stroke="red"
                   StrokeDashArray="5 3"
                   StrokeThickness="3" />
        <Border x:Name="border"
                BorderThickness="1"
                BorderBrush="#FF3A465A"
                Padding="5">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="18" />
                    <RowDefinition />
                    <RowDefinition Height="18" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="18" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Image x:Name="documentIcon"
                       Grid.Column="0"
                       Grid.Row="0"
                       Width="16"
                       Height="16"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Stretch="UniformToFill"
                       Source="{Binding Icon, ElementName=userControl}" />

                <TextBlock x:Name="documentName"
                           TextTrimming="WordEllipsis"
                           UseLayoutRounding="False"
                           Grid.Column="1"
                           Text="{Binding Title, ElementName=userControl}"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Center"
                           Margin="5,0,0,0" />

                <Image x:Name="documentThumbnail"
                       Grid.Row="1"
                       Grid.ColumnSpan="2"
                       Source="{Binding ImageSource, ElementName=userControl}"
                       Margin="0,2" />

                <StackPanel Orientation="Horizontal"
                            Grid.Row="2"
                            Grid.Column="0"
                            Grid.ColumnSpan="2"
                            HorizontalAlignment="Right">

                    <Border Height="14"
                            BorderBrush="#FF353535"
                            BorderThickness="1"
                            Background="White"
                            Visibility="{Binding NumberPages, Converter={StaticResource NumberPagesToVisibilityConverter}, ElementName=userControl}"
                            Padding="2,0">
                        <TextBlock Foreground="Black"
                                   FontWeight="Bold"
                                   Text="{Binding NumberPages, ElementName=userControl}"
                                   VerticalAlignment="Center" />
                    </Border>
                </StackPanel>
                <Image HorizontalAlignment="Left"
                       Height="24"
                       VerticalAlignment="Bottom"
                       Width="24"
                       Grid.RowSpan="3"
                       Grid.ColumnSpan="3"
                       Source="{Binding WorkflowState, Converter={StaticResource WorkflowStateToIconConverter}, ElementName=userControl}" />

            </Grid>
        </Border>
    </Grid>
</UserControl>